package logic

import (
	"context"

	"xialou_platform/services/wallet/rpc/internal/svc"
	"xialou_platform/services/wallet/rpc/walletClient"

	"github.com/zeromicro/go-zero/core/logx"
)

type AgentProfitLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewAgentProfitLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AgentProfitLogic {
	return &AgentProfitLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// AgentProfit 销氪收益
func (l *AgentProfitLogic) AgentProfit(in *walletClient.AgentProfitReq) (*walletClient.AgentProfitResp, error) {

	return &walletClient.AgentProfitResp{
		CardNum:     l.svcCtx.WalletLogModel.FindCountByBusiness(l.ctx, 1, in.AgentId),
		CardProfit:  l.svcCtx.WalletLogModel.FindProfitByBusiness(l.ctx, 1, in.AgentId),
		GroupProfit: l.svcCtx.WalletLogModel.FindProfitByBusiness(l.ctx, 2, in.AgentId),
		PayProfit:   l.svcCtx.WalletLogModel.FindProfitByBusiness(l.ctx, 3, in.AgentId),
	}, nil
}
